package config_manager

import (
	"go_server/game_server/dataconfig/configpb"
	"go_server/zinx/zlog"
)

// 获取单个单个商店配置数据
func GetStcTableShop_SheetShopById(id int32) (configpb.StcTableShop_SheetShop_29EA6FE4, bool) {
	config, ok := tableShopSheetShop[id]
	if !ok {
		zlog.Errorf("GetStcTableTask_SheetTask Err!!! id: %d", id)
		return configpb.StcTableShop_SheetShop_29EA6FE4{}, false
	}

	return configpb.StcTableShop_SheetShop_29EA6FE4{
		Id:        config.Id,
		Type:      config.Type,
		Itemid:    config.Itemid,
		Price:     config.Price,
		Number:    config.Number,
		Buytype:   config.Buytype,
		Buynumber: config.Buynumber,
		Discount:  config.Discount,
	}, true
}

// 获取商店配置列表 (每周刷新)
func GetStcTableShop_SheetShopListByWeek(buyType int32) map[int32]*configpb.StcTableShop_SheetShop_29EA6FE4 {
	allConfig := make(map[int32]*configpb.StcTableShop_SheetShop_29EA6FE4)

	if tableShopSheetShop != nil {
		for _, config := range tableShopSheetShop {
			if buyType != config.Buytype { //筛选出有限购次数的商店配置
				row := configpb.StcTableShop_SheetShop_29EA6FE4{
					Id:        config.Id,
					Type:      config.Type,
					Itemid:    config.Itemid,
					Price:     config.Price,
					Number:    config.Number,
					Buytype:   config.Buytype,
					Buynumber: config.Buynumber,
					Discount:  config.Discount,
				}
				allConfig[config.Id] = &row
			}
		}
	}
	return allConfig
}
